package com.ferris.androidpattern;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

import com.ferris.observice.Student;
import com.ferris.observice.Student.Listeming;
import com.ferris.observice.Teacher;

public class StrategyActivity extends Activity {
	private Teacher teacher;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.strategy);
		teacher=new Teacher(); //被观察者
		
		Student student=new Student();
		student.setContext(this);
		student.setGirl(teacher);//添加观察对象
		student.setListeming(new Listeming() {
			@Override
			public void lisetem(String sss) {
				// TODO Auto-generated method stub
				Toast.makeText(StrategyActivity.this, "收到", 1).show();
			}
		});
		teacher.addObserver(student);
		findViewById(R.id.button1).setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				teacher.Speak("大家好我是老师哦！");
			}
		} );
		
	}

	

}
